package com.simon.mengkou.ui.activity;

import android.content.Context;
import android.graphics.Paint;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.ouertech.android.agm.lib.base.utils.UtilLog;
import com.simon.mengkou.R;
import com.simon.mengkou.data.bean.base.Category;
import com.simon.mengkou.data.bean.base.Image;
import com.simon.mengkou.data.bean.base.Product;
import com.simon.mengkou.system.global.OuerApplication;
import com.simon.mengkou.system.global.OuerDispatcher;
import com.simon.mengkou.ui.adapter.AbsAdapter;
import com.simon.mengkou.ui.adapter.DiscoveryProductAdapter;
import com.simon.mengkou.utils.UtilOuer;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by xiazhenshui on 16/6/11.
 */

public class CategoryAdapter extends AbsAdapter<Category> {
    public CategoryAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
        final CategoryAdapter.Holder holder;
        if (null == convertView) {
            convertView = mInflater.inflate(R.layout.layout_category_item, null);
            holder = new CategoryAdapter.Holder();
            convertView.setTag(holder);
            ButterKnife.bind(holder, convertView);
        } else {
            holder = (CategoryAdapter.Holder) convertView.getTag();
        }

        final Category data = getItem(position);
        //banner图片
        if(data.getImage() != null) {
            OuerApplication.mImageLoader.loadImage(holder.mSdvImage, data.getImage().getUrl());
        }

        return convertView;
    }


    /**
     * @author zhenshui.xia
     */
    class Holder {
        //分类图片
        @Bind(R.id.category_id_item)
        SimpleDraweeView mSdvImage;
    }
}
